import { ref } from "vue";

export function useEditColumns() {
  const columns: TableColumnList = [
    {
      label: "SKU_ID",
      prop: "id"
    },
    {
      label: "产品",
      prop: "sub_title",
      cellRenderer: ({ row }) => <el-input v-model={row.sub_title} />
    },
    {
      label: "资金",
      prop: "money",
      cellRenderer: ({ row }) => (
        <el-input-number
          precision={2}
          step={100}
          modelValue={parseFloat(row.money)}
          onUpdate:modelValue={val => (row.money = val ? val.toString() : "0")}
        />
      )
    },
    {
      label: "周期",
      prop: "cycle",
      cellRenderer: ({ row }) => (
        <el-input-number precision={0} step={1} v-model={row.cycle} />
      )
    },
    {
      label: "收益率",
      prop: "income",
      cellRenderer: ({ row }) => (
        <el-input-number
          precision={2}
          step={0.1}
          modelValue={parseFloat(row.income)}
          onUpdate:modelValue={val => (row.income = val ? val.toString() : "0")}
        />
      )
    },
    {
      label: "操作",
      slot: "operation",
      width: 140,
      fixed: "right"
    }
  ];

  return {
    editColumns: columns
  };
}
